package com.xiaoyi.library.service.impl;

import com.xiaoyi.library.mapper.BookMapper;
import com.xiaoyi.library.pojo.Book;
import com.xiaoyi.library.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {
    private final BookMapper bookMapper;

    @Autowired
    public BookServiceImpl(BookMapper bookMapper) {
        this.bookMapper = bookMapper;
    }

    @Override
    public List<Book> find() {
        return bookMapper.find();
    }

    @Override
    public List<Book> findByName(String bookName) {
        return bookMapper.findByName(bookName);
    }

    @Override
    public boolean deleteById(int bookId) {
        return bookMapper.deleteById(bookId);
    }

    @Override
    public boolean insert(Book book) {
        return bookMapper.insert(book);
    }

    @Override
    public boolean update(Book book) {
        return bookMapper.update(book);
    }
}
